package routers // routers包

import (
    "fmt"
    "github.com/gin-gonic/gin"

    "ginframe/logger"
    "ginframe/process/http"
)

// 路由中间件
func MiddleWare() gin.HandlerFunc {
    return func(c *gin.Context) {
        fmt.Println("中间件执行完毕")
        c.Next()
    }
}

func SetupRouter() *gin.Engine {
    engine := gin.Default()
    // 注册中间件：拦截和日志
    engine.Use(MiddleWare())
    engine.Use(logger.LogMiddleWare())
    // 注册路由/路由组
    engine.Any("/", http.WebRoot)
    engine.GET("/ping", http.PingHandler) 
    mixlog := engine.Group("/log")  
    {
        mixlog.GET("/list", http.GetMixlogList)
    }

    return engine
}
